package util

import (
	"encoding/json"
	"fmt"
	"github.com/astaxie/beego/logs"
	"time"
)

var Log *logs.BeeLogger

func init()  {
	//缓存的大小
	Log = logs.NewLogger(10000)
	//输出文件名和行号
	Log.EnableFuncCallDepth(true)
	//异步输出日志
	Log.Async()
	//引擎配置设置
	fileMap := make(map[string]string)
	filename := fmt.Sprintf("log/%s/%s.log", time.Now().Format("2006-01"), time.Now().Format("2006-01-02"))
	fileMap["filename"] = filename
	fileMapStr, _ := json.Marshal(fileMap)  //{"filename":"log/2020-09/2020-09-23.log"}
	err := Log.SetLogger("file",string(fileMapStr))
	fmt.Println("open log",err)
}